package com.edu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.edu.entity.CrmBanner;
import com.edu.mapper.CrmBannerMapper;
import com.edu.service.CrmBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2021-07-02
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {

	@Cacheable(key = "'selectIndexList'",value = "banner")
	@Override
	public List<CrmBanner> selectAllBanner() {

		//根据id进行降序排列，显示排列之后的前两条记录
		QueryWrapper<CrmBanner> wrapper = new QueryWrapper<>();
		wrapper.orderByDesc("id");
		wrapper.last("limit 2");
		List<CrmBanner> list = baseMapper.selectList(wrapper);
		return list;
	}


}
